/**
 * 作者: chenlingzhi
 * 日期: 2024-12-20 16:37:33
 * 备注: 充值记录表（直接入库）
 */
package com.motu.monstercity.server.game.userdata;

import com.motu.vertx.module.utility.model.BaseModel;
import com.motu.vertx.module.utility.model.Model;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;

public class IapRecordModel extends BaseModel implements Model {
    public static final String LISTKEY = "user_id";
    public static final int REDIS_EXPIRE_TIME = 0;// redis过期时间
    public static final int UPDATE_DB_TYPE = UPDATE_DB_TYPE_NOW;// 数据入库类型 直接入库
    public static final boolean ORDER_LIST = false;// 是否需要额外的有序列表

    protected long id; // id
    protected long userId; // 用户ID
    protected String userName = ""; // 用户昵称
    protected int serverId; // 服务器Id
    protected int level; // 充值时用户等级
    protected int vip; // 充值时用户vip
    protected int platform; // 平台号
    protected long channel; // 渠道号
    protected int iapGiftId; // 充值礼包id
    protected int diamond; // 总钻石
    protected String productId = ""; // 产品Id
    protected String orderId = ""; // 订单Id
    protected double money; // 金额
    protected String transInfo = ""; // 订单信息
    protected byte isMiss; // 是否为漏单
    protected byte isFake; // 是否为虚拟补单
    protected byte isVoided; // 是否退款
    protected long voidedTime; // 退款时间
    protected long addTime; // 订单时间
    protected int iapId; // 充值项id
    protected int actRechargeType; // 活动充值类型

    public void reset() {
    }

    protected String getKey() {
        return "IapRecord." + id;
    }

    protected String getListKey() {
        return "IapRecord." + userId;
    }

    protected String getListItemKey() {
        return id + "";
    }

    public void doCreate() {
        setTableId();
        insert();
    }

    public void setTableId() {
        putId(incrTableId("iap_record"));
    }

    public JsonObject insert() {
        return super.insert(getKey(), id, REDIS_EXPIRE_TIME, UPDATE_DB_TYPE, LISTKEY, getListKey(), getListItemKey(), ORDER_LIST);
    }

    public void delete() {
        super.delete(getKey(), id, UPDATE_DB_TYPE, 0, LISTKEY, getListKey(), getListItemKey(), ORDER_LIST);
    }

    /**
     * 根据入库类型更新
     */
    public JsonObject update() {
        return super.update(getKey(), id, REDIS_EXPIRE_TIME, UPDATE_DB_TYPE, 0, getAllObj(), LISTKEY, getListKey(), getListItemKey());
    }

    /**
     * 实时入队列
     */
    public JsonObject updateQueueNow() {
        return super.update(getKey(), id, REDIS_EXPIRE_TIME, UPDATE_DB_TYPE, 0, getAllObj(), LISTKEY, getListKey(), getListItemKey());
    }

    public JsonObject getAllObj(){
        JsonObject obj = new JsonObject();
        obj.put("id", id); // id
        obj.put("userId", userId); // 用户ID
        obj.put("userName", userName); // 用户昵称
        obj.put("serverId", serverId); // 服务器Id
        obj.put("level", level); // 充值时用户等级
        obj.put("vip", vip); // 充值时用户vip
        obj.put("platform", platform); // 平台号
        obj.put("channel", channel); // 渠道号
        obj.put("iapGiftId", iapGiftId); // 充值礼包id
        obj.put("diamond", diamond); // 总钻石
        obj.put("productId", productId); // 产品Id
        obj.put("orderId", orderId); // 订单Id
        obj.put("money", money); // 金额
        obj.put("transInfo", transInfo); // 订单信息
        obj.put("isMiss", isMiss); // 是否为漏单
        obj.put("isFake", isFake); // 是否为虚拟补单
        obj.put("isVoided", isVoided); // 是否退款
        obj.put("voidedTime", voidedTime); // 退款时间
        obj.put("addTime", addTime); // 订单时间
        obj.put("iapId", iapId); // 充值项id
        obj.put("actRechargeType", actRechargeType); // 活动充值类型
        return obj;
    }

    public long getId() {
        return id;
    }

    public void putId(long id) {
        if (this.id != id) {
            this.id = id;
            updateRedisHashField(getKey(), "id", this.id);
        }
    }

    public void addId(long value) {
        this.id += value;
        updateRedisHashField(getKey(), "id", this.id);
    }

    public long getUserId() {
        return userId;
    }

    public void putUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            updateRedisHashField(getKey(), "userId", this.userId);
        }
    }

    public void addUserId(long value) {
        this.userId += value;
        updateRedisHashField(getKey(), "userId", this.userId);
    }

    public String getUserName() {
        return userName;
    }

    public void putUserName(String userName) {
        if (!this.userName.equals(userName)) {
            this.userName = userName;
            updateRedisHashField(getKey(), "userName", this.userName);
        }
    }

    public int getServerId() {
        return serverId;
    }

    public void putServerId(int serverId) {
        if (this.serverId != serverId) {
            this.serverId = serverId;
            updateRedisHashField(getKey(), "serverId", this.serverId);
        }
    }

    public void addServerId(int value) {
        this.serverId += value;
        updateRedisHashField(getKey(), "serverId", this.serverId);
    }

    public int getLevel() {
        return level;
    }

    public void putLevel(int level) {
        if (this.level != level) {
            this.level = level;
            updateRedisHashField(getKey(), "level", this.level);
        }
    }

    public void addLevel(int value) {
        this.level += value;
        updateRedisHashField(getKey(), "level", this.level);
    }

    public int getVip() {
        return vip;
    }

    public void putVip(int vip) {
        if (this.vip != vip) {
            this.vip = vip;
            updateRedisHashField(getKey(), "vip", this.vip);
        }
    }

    public void addVip(int value) {
        this.vip += value;
        updateRedisHashField(getKey(), "vip", this.vip);
    }

    public int getPlatform() {
        return platform;
    }

    public void putPlatform(int platform) {
        if (this.platform != platform) {
            this.platform = platform;
            updateRedisHashField(getKey(), "platform", this.platform);
        }
    }

    public void addPlatform(int value) {
        this.platform += value;
        updateRedisHashField(getKey(), "platform", this.platform);
    }

    public long getChannel() {
        return channel;
    }

    public void putChannel(long channel) {
        if (this.channel != channel) {
            this.channel = channel;
            updateRedisHashField(getKey(), "channel", this.channel);
        }
    }

    public void addChannel(long value) {
        this.channel += value;
        updateRedisHashField(getKey(), "channel", this.channel);
    }

    public int getIapGiftId() {
        return iapGiftId;
    }

    public void putIapGiftId(int iapGiftId) {
        if (this.iapGiftId != iapGiftId) {
            this.iapGiftId = iapGiftId;
            updateRedisHashField(getKey(), "iapGiftId", this.iapGiftId);
        }
    }

    public void addIapGiftId(int value) {
        this.iapGiftId += value;
        updateRedisHashField(getKey(), "iapGiftId", this.iapGiftId);
    }

    public int getDiamond() {
        return diamond;
    }

    public void putDiamond(int diamond) {
        if (this.diamond != diamond) {
            this.diamond = diamond;
            updateRedisHashField(getKey(), "diamond", this.diamond);
        }
    }

    public void addDiamond(int value) {
        this.diamond += value;
        updateRedisHashField(getKey(), "diamond", this.diamond);
    }

    public String getProductId() {
        return productId;
    }

    public void putProductId(String productId) {
        if (!this.productId.equals(productId)) {
            this.productId = productId;
            updateRedisHashField(getKey(), "productId", this.productId);
        }
    }

    public String getOrderId() {
        return orderId;
    }

    public void putOrderId(String orderId) {
        if (!this.orderId.equals(orderId)) {
            this.orderId = orderId;
            updateRedisHashField(getKey(), "orderId", this.orderId);
        }
    }

    public double getMoney() {
        return money;
    }

    public void putMoney(double money) {
        if (this.money != money) {
            this.money = money;
            updateRedisHashField(getKey(), "money", this.money);
        }
    }

    public void addMoney(double value) {
        this.money += value;
        updateRedisHashField(getKey(), "money", this.money);
    }

    public String getTransInfo() {
        return transInfo;
    }

    public void putTransInfo(String transInfo) {
        if (!this.transInfo.equals(transInfo)) {
            this.transInfo = transInfo;
            updateRedisHashField(getKey(), "transInfo", this.transInfo);
        }
    }

    public byte getIsMiss() {
        return isMiss;
    }

    public void putIsMiss(byte isMiss) {
        if (this.isMiss != isMiss) {
            this.isMiss = isMiss;
            updateRedisHashField(getKey(), "isMiss", this.isMiss);
        }
    }

    public void addIsMiss(byte value) {
        this.isMiss += value;
        updateRedisHashField(getKey(), "isMiss", this.isMiss);
    }

    public byte getIsFake() {
        return isFake;
    }

    public void putIsFake(byte isFake) {
        if (this.isFake != isFake) {
            this.isFake = isFake;
            updateRedisHashField(getKey(), "isFake", this.isFake);
        }
    }

    public void addIsFake(byte value) {
        this.isFake += value;
        updateRedisHashField(getKey(), "isFake", this.isFake);
    }

    public byte getIsVoided() {
        return isVoided;
    }

    public void putIsVoided(byte isVoided) {
        if (this.isVoided != isVoided) {
            this.isVoided = isVoided;
            updateRedisHashField(getKey(), "isVoided", this.isVoided);
        }
    }

    public void addIsVoided(byte value) {
        this.isVoided += value;
        updateRedisHashField(getKey(), "isVoided", this.isVoided);
    }

    public long getVoidedTime() {
        return voidedTime;
    }

    public void putVoidedTime(long voidedTime) {
        if (this.voidedTime != voidedTime) {
            this.voidedTime = voidedTime;
            updateRedisHashField(getKey(), "voidedTime", this.voidedTime);
        }
    }

    public void addVoidedTime(long value) {
        this.voidedTime += value;
        updateRedisHashField(getKey(), "voidedTime", this.voidedTime);
    }

    public long getAddTime() {
        return addTime;
    }

    public void putAddTime(long addTime) {
        if (this.addTime != addTime) {
            this.addTime = addTime;
            updateRedisHashField(getKey(), "addTime", this.addTime);
        }
    }

    public void addAddTime(long value) {
        this.addTime += value;
        updateRedisHashField(getKey(), "addTime", this.addTime);
    }

    public int getIapId() {
        return iapId;
    }

    public void putIapId(int iapId) {
        if (this.iapId != iapId) {
            this.iapId = iapId;
            updateRedisHashField(getKey(), "iapId", this.iapId);
        }
    }

    public void addIapId(int value) {
        this.iapId += value;
        updateRedisHashField(getKey(), "iapId", this.iapId);
    }

    public int getActRechargeType() {
        return actRechargeType;
    }

    public void putActRechargeType(int actRechargeType) {
        if (this.actRechargeType != actRechargeType) {
            this.actRechargeType = actRechargeType;
            updateRedisHashField(getKey(), "actRechargeType", this.actRechargeType);
        }
    }

    public void addActRechargeType(int value) {
        this.actRechargeType += value;
        updateRedisHashField(getKey(), "actRechargeType", this.actRechargeType);
    }

}